%%HTML
<style> code {background-color : pink !important;} </style>
import numpy as np
import cv2
import glob
import matplotlib.pyplot as plt
import pickle
%matplotlib inline
# inner points in x and y directions
nx=9
ny=6
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0) - coordinates of the inner points - z axis value
# is 0 for all
# 20 calibration images are taken from camera_cal folder and findChessboardCorners function is used to
# map objpoints to imgpoints
objp = np.zeros((ny*nx,3), np.float32)
objp[:,:2] = np.mgrid[0:nx, 0:ny].T.reshape(-1,2)
# Arrays to store object points and image points from all the images.
objpoints = [] # 3d points in real world space
imgpoints = [] # 2d points in image plane.
# Make a list of calibration images
images = glob.glob('camera_cal/CALI*.jpg')
imgshape = None
imgCount = 0
# Step through the list and search for chessboard corners
for idx, fname in enumerate(images):
img = cv2.imread(fname)
imgshape = img.shape
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Find the chessboard corners
ret, corners = cv2.findChessboardCorners(gray, (nx,ny), None)
# If found, add object points, image points
if ret == True:
objpoints.append(objp)
imgpoints.append(corners)
# Draw and display the corners
img = cv2.drawChessboardCorners(img, (nx,ny), corners, ret)
#write_name = 'corners_found'+str(idx)+'.jpg'
#cv2.imwrite(write_name, img)
#print(fname)
if fname == 'camera_cal\calibration3.jpg':
cv2.imwrite('camera_cal/calibration3_corners.jpg',img)
f, ax1 = plt.subplots(1, 1, figsize=(20,10))
ax1.imshow(img)
ax1.set_title('Original Image with Corners', fontsize=30)
imgCount+= 1
cv2.imshow('img', img)
cv2.waitKey(500)
cv2.destroyAllWindows()
objpoints and imgpoints needed for camera calibration. Run the cell below to calibrate, calculate distortion coefficients, and test undistortion on an image!¶# After getting imgpoints corresponding to objPoints, calibrateCamera function is used to get mtx and dist matrices
# to remove distortion from images
# Test undistortion on an image
img = cv2.imread('camera_cal/calibration3.jpg')
img = cv2.resize(img,(imgshape[1],imgshape[0]) )
img_size = (img.shape[1], img.shape[0])
# Do camera calibration given object points and image points
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img_size,None,None)
undist = cv2.undistort(img, mtx, dist, None, mtx)
cv2.imwrite('camera_cal/calibration3_undist.jpg',undist)
# Save the camera calibration result for later use (we won't worry about rvecs / tvecs)
dist_pickle = {}
dist_pickle["mtx"] = mtx
dist_pickle["dist"] = dist
pickle.dump( dist_pickle, open( "camera_cal/wide_dist_pickle_new.p", "wb" ) )
#dst = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)
# Visualize undistortion
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(20,10))
ax1.imshow(img)
ax1.set_title('Original Image', fontsize=30)
ax2.imshow(undist)
ax2.set_title('Undistorted Image', fontsize=30)
# Test undistortion on an image
img = cv2.imread('test_images/test1.jpg')
img = cv2.resize(img,(imgshape[1],imgshape[0]) )
img_size = (img.shape[1], img.shape[0])
# Do camera calibration given object points and image points
#ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img_size,None,None)
dist_pickle = {}
with open("camera_cal/wide_dist_pickle_new.p", mode='rb') as f:
dist_pickle = pickle.load(f)
savedMtx = np.float64(dist_pickle["mtx"])
savedDist = np.float64(dist_pickle["dist"])
undist = cv2.undistort(img, savedMtx, savedDist, None, savedMtx)
cv2.imwrite('test_images/undist_test1.jpg',undist)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
undist = cv2.cvtColor(undist, cv2.COLOR_BGR2RGB)
# Visualize undistortion
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(20,10))
ax1.imshow(img)
ax1.set_title('Original Image', fontsize=30)
ax2.imshow(undist)
ax2.set_title('Undistorted Image', fontsize=30)
ksize = 3
def abs_sobel_thresh(img, orient='x', sobel_kernel=3, thresh = (0, 255)):
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
#gray = img
if orient == 'x':
sobel = cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksize=sobel_kernel)
else:
sobel = cv2.Sobel(gray, cv2.CV_64F, 0, 1,ksize = sobel_kernel)
abs_sobel = np.absolute(sobel)
scaled_sobel = np.uint8(255*abs_sobel/np.max(abs_sobel))
binary_output = np.zeros_like(scaled_sobel)
binary_output[(scaled_sobel >= thresh[0]) & (scaled_sobel <= thresh[1]) ] = 1
#binary_output = np.copy(img) # Remove this line
return binary_output
def mag_thresh(image, sobel_kernel=3, mag_thresh=(0, 255)):
# Calculate gradient magnitude
# Apply threshold
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
sobelx = cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksize=sobel_kernel)
sobely = cv2.Sobel(gray, cv2.CV_64F, 0, 1, ksize=sobel_kernel)
gradmag = np.sqrt(sobelx**2 + sobely**2)
scaled_sobel = np.uint8(255*gradmag/np.max(gradmag))
mag_binary = np.zeros_like(scaled_sobel)
mag_binary[(scaled_sobel >= mag_thresh[0]) & (scaled_sobel <= mag_thresh[1])] = 1
return mag_binary
def dir_threshold(image, sobel_kernel=3, thresh=(0, np.pi/2)):
# Calculate gradient direction
# Apply threshold
gray = cv2.cvtColor(image,cv2.COLOR_RGB2GRAY)
sobelx = cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksize=sobel_kernel)
sobely = cv2.Sobel(gray, cv2.CV_64F, 0, 1, ksize=sobel_kernel)
absgraddir = np.arctan2(np.absolute(sobely), np.absolute(sobelx))
dir_binary = np.zeros_like(absgraddir)
dir_binary[(absgraddir >= thresh[0]) & (absgraddir <= thresh[1])] = 1
return dir_binary
def color_threshold(image, sobel_kernel=3, threshS=(0, np.pi/2),threshL=(0, np.pi/2), threshV=(0, np.pi/2)):
# Calculate gradient direction
# Apply threshold
hls = cv2.cvtColor(image, cv2.COLOR_RGB2HLS)
H = hls[:,:,0]
L = hls[:,:,1]
S = hls[:,:,2]
#thresh = (100, 255)#90,255
#threshL = threshV
binary_L = np.zeros_like(L)
binary_L[(L > threshL[0]) & (L <= threshL[1])] = 1
binary_S = np.zeros_like(S)
binary_S[(S > threshS[0]) & (S <= threshS[1])] = 1
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
H = hls[:,:,0]
S = hls[:,:,1]
V = hls[:,:,2]
binary_V = np.zeros_like(V)
binary_V[(V > threshV[0]) & (V <= threshV[1])] = 1
combined_SV = np.zeros_like(binary_S)
combined_SV[((binary_S == 1) & ((binary_V == 1)))] = 1
combined_SL = np.zeros_like(binary_S)
combined_SL[((binary_S == 1) & ((binary_L == 1)))] = 1
combined_SLV = np.zeros_like(binary_S)
combined_SLV[((binary_S == 1) & (binary_L == 1) & (binary_V == 1) )] = 1
return combined_SLV
def createBinary(img):
gradx = abs_sobel_thresh(img, orient='x', sobel_kernel=ksize, thresh=(12, 255))
grady = abs_sobel_thresh(img, orient='y', sobel_kernel=ksize, thresh=(25, 255))
#mag_binary = mag_thresh(img, sobel_kernel=ksize, mag_thresh=(30, 150)) #30,150
#dir_binary = dir_threshold(img, sobel_kernel=ksize, thresh=(0.7, 1.3))
combined = np.zeros_like(gradx)
#combined[((gradx == 1) & (grady == 1)) | ((mag_binary == 1) & (dir_binary == 1))] = 1
combined[((gradx == 1) & (grady == 1)) ] = 1
color_binary = color_threshold(img, sobel_kernel=ksize, threshS = (80,255), threshL = (50,200), threshV = (50,225))
combined_SVgradXY = np.zeros_like(color_binary)
combined_SVgradXY[(combined == 1) | ((color_binary == 1))] = 1
return combined_SVgradXY
testImages = glob.glob('test_images/test*.jpg')
#imgCount = 0
# Step through the list and search for chessboard corners
for idx, fname in enumerate(testImages):
img = cv2.imread(fname)
imgshape = img.shape
img = cv2.resize(img,(imgshape[1],imgshape[0]) )
img_size = (img.shape[1], img.shape[0])
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
img = cv2.undistort(img, mtx, dist, None, mtx)
combined_SVgradXY = createBinary(img)
outputFileName = 'test_images/binary_test' +str(idx + 1) + ".png"
#cv2.imwrite(outputFileName,combined_SVgradXY, cmap=cm.gray)
plt.imsave(outputFileName,combined_SVgradXY, cmap='gray')
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 9))
f.tight_layout()
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
ax1.imshow(img)
ax1.set_title('Original Image', fontsize=50)
ax2.imshow(combined_SVgradXY, cmap='gray')
ax2.set_title('Thresholded Grad. Dir.', fontsize=50)
plt.subplots_adjust(left=0., right=1, top=0.9, bottom=0.)
plt.show()
def warper(img, nx, ny, src,dest,mtx, dist):
M = cv2.getPerspectiveTransform(np.array(src), np.array(dest))
MInv = cv2.getPerspectiveTransform(np.array(dest), np.array(src))
#warped = cv2.warpPerspective(img, M, img_size,flags=cv2.INTER_NEAREST)
warped = cv2.warpPerspective(img, M, img_size,flags=cv2.INTER_LINEAR)
return warped, M, MInv
def setSrcDestVertices():
src = np.float32([[575, 460], [300, 705], [1115, 705], [700, 460]])
dst = np.float32([[310, 0], [310, 700], [1000,700], [1000, 0]])
return src, dst
img = cv2.imread('test_images/test1.jpg')
img = cv2.resize(img,(imgshape[1],imgshape[0]) )
img_size = (img.shape[1], img.shape[0])
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
src_in, dst_in = setSrcDestVertices()
img = cv2.line(img, (src_in[0][0],src_in[0][1]), (src_in[1][0],src_in[1][1]), color = (0,0,255), thickness=3)
img = cv2.line(img, (src_in[1][0],src_in[1][1]), (src_in[2][0],src_in[2][1]), color = (0,0,255), thickness=3)
img = cv2.line(img, (src_in[2][0],src_in[2][1]), (src_in[3][0],src_in[3][1]), color = (0,0,255), thickness=3)
img = cv2.line(img, (src_in[3][0],src_in[3][1]), (src_in[0][0],src_in[0][1]), color = (0,0,255), thickness=3)
#cv2.imwrite('test_images/src_test1.png',img)
plt.imsave('test_images/src_test1.png',img)
img = cv2.undistort(img, mtx, dist, None, mtx) # line added
#combined_SVgradXY = createBinary(img)
warped = warper(img, nx, ny, src_in, dst_in, mtx, dist)
#binary_warped = warped[0]
#M = warped[1]
#MInv = warped[2]
#cv2.imwrite('test_images/warped_test1.png',warped[0])
plt.imsave('test_images/warped_test1.png',warped[0])
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(24, 9))
f.tight_layout()
ax1.imshow(img)
ax1.set_title('Original Image', fontsize=50)
ax2.imshow(warped[0])
ax2.set_title('Warped', fontsize=50)
plt.subplots_adjust(left=0., right=1, top=0.9, bottom=0.)
plt.show()
src_in, dst_in = setSrcDestVertices()
img = cv2.imread('test_images/test2.jpg')
img = cv2.resize(img,(imgshape[1],imgshape[0]) )
img_size = (img.shape[1], img.shape[0])
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
img = cv2.undistort(img, mtx, dist, None, mtx) # line added
combined_SVgradXY = createBinary(img)
warped = warper(combined_SVgradXY, nx, ny, src_in, dst_in, mtx, dist)
binary_warped = warped[0]
histogram = np.sum(binary_warped[binary_warped.shape[0] * 0.5:,:], axis=0)
plt.plot(histogram)
def getLeftAndRightTracks(binary_warped,drawRectangle):
histogram = np.sum(binary_warped[binary_warped.shape[0]*0.5:,:], axis=0)
out_img = np.dstack((binary_warped, binary_warped, binary_warped))*255
midpoint = np.int(histogram.shape[0]/2)
leftx_base = np.argmax(histogram[:midpoint])
rightx_base = np.argmax(histogram[midpoint:]) + midpoint
# Choose the number of sliding windows
nwindows = 9
# Set height of windows
window_height = np.int(binary_warped.shape[0]/nwindows)
window_width = 80 #80
# Identify the x and y positions of all nonzero pixels in the image
nonzero = binary_warped.nonzero()
nonzeroy = np.array(nonzero[0])
nonzerox = np.array(nonzero[1])
# Current positions to be updated for each window
leftx_current = leftx_base
rightx_current = rightx_base
# Set the width of the windows +/- margin
margin = 80#80
# Set minimum number of pixels found to recenter window
minpix = 40
# Create empty lists to receive left and right lane pixel indices
left_lane_inds = []
right_lane_inds = []
# Step through the windows one by one
for window in range(nwindows):
# Identify window boundaries in x and y (and right and left)
win_y_low = binary_warped.shape[0] - (window + 1)* window_height
win_y_high = binary_warped.shape[0] - window*window_height
win_xleft_low = leftx_current - margin
win_xleft_high = leftx_current + margin
win_xright_low = rightx_current - margin
win_xright_high = rightx_current + margin
# Draw the windows on the visualization image
if drawRectangle:
cv2.rectangle(out_img,(win_xleft_low,win_y_low),(win_xleft_high,win_y_high),(0,255,0), 2)
cv2.rectangle(out_img,(win_xright_low,win_y_low),(win_xright_high,win_y_high),(0,255,0), 2)
# Identify the nonzero pixels in x and y within the window
good_left_inds = ((nonzeroy >= win_y_low) & (nonzeroy < win_y_high) & (nonzerox >= win_xleft_low) & (nonzerox < win_xleft_high)).nonzero()[0]
good_right_inds = ((nonzeroy >= win_y_low) & (nonzeroy < win_y_high) & (nonzerox >= win_xright_low) & (nonzerox < win_xright_high)).nonzero()[0]
# Append these indices to the lists
left_lane_inds.append(good_left_inds)
right_lane_inds.append(good_right_inds)
# If you found > minpix pixels, recenter next window on their mean position
if len(good_left_inds) > minpix:
leftx_current = np.int(np.mean(nonzerox[good_left_inds]))
if len(good_right_inds) > minpix:
rightx_current = np.int(np.mean(nonzerox[good_right_inds]))
# Concatenate the arrays of indices
left_lane_inds = np.concatenate(left_lane_inds)
right_lane_inds = np.concatenate(right_lane_inds)
nonzero = binary_warped.nonzero()
nonzeroy = np.array(nonzero[0])
nonzerox = np.array(nonzero[1])
leftx = nonzerox[left_lane_inds]
lefty = nonzeroy[left_lane_inds]
rightx = nonzerox[right_lane_inds]
righty = nonzeroy[right_lane_inds]
#return out_img, left_fitx, right_fitx, left_lane_inds, right_lane_inds, ploty
return leftx, lefty, rightx, righty, out_img, left_lane_inds, right_lane_inds
def fitPoly(binary_warped, out_img, leftx, lefty,rightx, righty ,left_lane_inds, right_lane_inds,iCount):
# Extract left and right line pixel positions
# Identify the x and y positions of all nonzero pixels in the image
nonzero = binary_warped.nonzero()
nonzeroy = np.array(nonzero[0])
nonzerox = np.array(nonzero[1])
# Fit a second order polynomial to each
left_fit = np.polyfit(lefty, leftx, 2)
right_fit = np.polyfit(righty, rightx, 2)
# Generate x and y values for plotting
ploty = np.linspace(0, binary_warped.shape[0]-1, binary_warped.shape[0] )
left_fitx = left_fit[0]*ploty**2 + left_fit[1]*ploty + left_fit[2]
right_fitx = right_fit[0]*ploty**2 + right_fit[1]*ploty + right_fit[2]
out_img[nonzeroy[left_lane_inds], nonzerox[left_lane_inds]] = [255, 0, 0]
out_img[nonzeroy[right_lane_inds], nonzerox[right_lane_inds]] = [0, 0, 255]
return out_img, left_fitx, right_fitx, ploty, left_fit,right_fit
def drawWindows(img):
img = cv2.resize(img,(imgshape[1],imgshape[0]) )
img_size = (img.shape[1], img.shape[0])
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
img = cv2.undistort(img, mtx, dist, None, mtx) # line added
combined_SVgradXY = createBinary(img)
src_in, dst_in = setSrcDestVertices()
warped = warper(combined_SVgradXY, nx, ny, src_in, dst_in, mtx, dist)
binary_warped = warped[0]
revM = warped[2]
leftx, lefty, rightx, righty, out_img, left_lane_inds, right_lane_inds = getLeftAndRightTracks(binary_warped,True)
out_img, left_fitx, right_fitx, ploty,left_fit,right_fit = fitPoly(binary_warped, out_img,leftx, lefty,rightx, righty, left_lane_inds, right_lane_inds,0)
window_img = np.zeros_like(out_img)
margin = 80
# Generate a polygon to illustrate the search window area
# And recast the x and y points into usable format for cv2.fillPoly()
left_line_window1 = np.array([np.transpose(np.vstack([left_fitx-margin, ploty]))])
left_line_window2 = np.array([np.flipud(np.transpose(np.vstack([left_fitx+margin, ploty])))])
left_line_pts = np.hstack((left_line_window1, left_line_window2))
right_line_window1 = np.array([np.transpose(np.vstack([right_fitx-margin, ploty]))])
right_line_window2 = np.array([np.flipud(np.transpose(np.vstack([right_fitx+margin, ploty])))])
right_line_pts = np.hstack((right_line_window1, right_line_window2))
# Draw the lane onto the warped blank image
cv2.fillPoly(window_img, np.int_([left_line_pts]), (0,255, 0))
cv2.fillPoly(window_img, np.int_([right_line_pts]), (0,255, 0))
left_curve = np.array([np.transpose(np.vstack([left_fitx, ploty]))])
cv2.polylines(window_img, np.int_([left_curve]), 0, (255,0,0), thickness=15)
right_curve = np.array([np.transpose(np.vstack([right_fitx, ploty]))])
cv2.polylines(window_img, np.int_([right_curve]), 0, (255,0,0), thickness=15)
#window_img = cv2.warpPerspective(window_img, revM, img_size,flags=cv2.INTER_NEAREST)
result = cv2.addWeighted(out_img, 1, window_img, 0.3, 0)
#result = cv2.addWeighted(img, 1, window_img, 0.3, 0)
#for i in range(len(left_line_pts) - 1):
# cv2.line(img, (x[i], y[i]), (x[i+1], y[i+1]), (0,0,0))
plt.imshow(result)
#plt.plot(left_fitx, ploty, color='yellow')
#plt.plot(right_fitx, ploty, color='yellow')
plt.xlim(0, 1280)
plt.ylim(720, 0)
return result
img = cv2.imread('test_images/test1.jpg')
result = drawWindows(img)
plt.imsave('test_images/windows_test1.png',result)
img = cv2.imread('test_images/test2.jpg')
result = drawWindows(img)
plt.imsave('test_images/windows_test2.png',result)
img = cv2.imread('test_images/test3.jpg')
result = drawWindows(img)
plt.imsave('test_images/windows_test3.png',result)
img = cv2.imread('test_images/test4.jpg')
result = drawWindows(img)
plt.imsave('test_images/windows_test4.png',result)
img = cv2.imread('test_images/test5.jpg')
result = drawWindows(img)
plt.imsave('test_images/windows_test5.png',result)
img = cv2.imread('test_images/test6.jpg')
result = drawWindows(img)
plt.imsave('test_images/windows_test6.png',result)
def drawLanes(img):
img = cv2.resize(img,(imgshape[1],imgshape[0]) )
img_size = (img.shape[1], img.shape[0])
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
img = cv2.undistort(img, mtx, dist, None, mtx) # line added
combined_SVgradXY = createBinary(img)
src_in, dst_in = setSrcDestVertices()
warped = warper(combined_SVgradXY, nx, ny, src_in, dst_in, mtx, dist)
binary_warped = warped[0]
revM = warped[2]
leftx, lefty, rightx, righty, out_img, left_lane_inds, right_lane_inds = getLeftAndRightTracks(binary_warped,True)
out_img, left_fitx, right_fitx, ploty,left_fit,right_fit = fitPoly(binary_warped, out_img,leftx, lefty,rightx, righty, left_lane_inds, right_lane_inds,0)
window_img = np.zeros_like(out_img)
margin = 80
# Generate a polygon to illustrate the search window area
# And recast the x and y points into usable format for cv2.fillPoly()
left_line_window1 = np.array([np.transpose(np.vstack([left_fitx-margin, ploty]))])
left_line_window2 = np.array([np.flipud(np.transpose(np.vstack([left_fitx+margin, ploty])))])
left_line_pts = np.hstack((left_line_window1, left_line_window2))
right_line_window1 = np.array([np.transpose(np.vstack([right_fitx-margin, ploty]))])
right_line_window2 = np.array([np.flipud(np.transpose(np.vstack([right_fitx+margin, ploty])))])
right_line_pts = np.hstack((right_line_window1, right_line_window2))
# Draw the lane onto the warped blank image
cv2.fillPoly(window_img, np.int_([left_line_pts]), (0,255, 0))
cv2.fillPoly(window_img, np.int_([right_line_pts]), (0,255, 0))
left_curve = np.array([np.transpose(np.vstack([left_fitx, ploty]))])
cv2.polylines(window_img, np.int_([left_curve]), 0, (255,0,0), thickness=15)
right_curve = np.array([np.transpose(np.vstack([right_fitx, ploty]))])
cv2.polylines(window_img, np.int_([right_curve]), 0, (255,0,0), thickness=15)
#window_img = cv2.warpPerspective(window_img, revM, img_size,flags=cv2.INTER_NEAREST)
window_img = cv2.warpPerspective(window_img, revM, img_size,flags=cv2.INTER_LINEAR)
result = cv2.addWeighted(img, 1, window_img, 0.3, 0)
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(24, 9))
f.tight_layout()
ax1.imshow(img)
ax1.set_title('Original Image', fontsize=50)
ax2.imshow(result)
ax2.set_title('Image with Lanes Drawn', fontsize=50)
plt.subplots_adjust(left=0., right=1, top=0.9, bottom=0.)
#plt.plot(left_fitx, ploty, color='yellow')
#plt.plot(right_fitx, ploty, color='yellow')
plt.xlim(0, 1280)
plt.ylim(720, 0)
return result
img = cv2.imread('test_images/test1.jpg')
result = drawLanes(img)
plt.imsave('test_images/DrawnLanes_test1.png',result)
img = cv2.imread('test_images/test2.jpg')
result = drawLanes(img)
plt.imsave('test_images/DrawnLanes_test2.png',result)
img = cv2.imread('test_images/test3.jpg')
result = drawLanes(img)
plt.imsave('test_images/DrawnLanes_test3.png',result)
img = cv2.imread('test_images/test4.jpg')
result = drawLanes(img)
plt.imsave('test_images/DrawnLanes_test4.png',result)
img = cv2.imread('test_images/test5.jpg')
result = drawLanes(img)
plt.imsave('test_images/DrawnLanes_test5.png',result)
img = cv2.imread('test_images/test6.jpg')
result = drawLanes(img)
plt.imsave('test_images/DrawnLanes_test6.png',result)